package rdw.http;
import java.util.Hashtable;
import java.util.StringTokenizer;

/**
 * UrlParameterDecoder decodes URL parameters into tokenized argument strings.
 */
public class UrlParameterDecoder
{
	private StringTokenizer tokens;
	
	private Hashtable<String, String> map;
	
	public UrlParameterDecoder(String url)
	{
		this.tokens = new StringTokenizer(url, "&");
		this.map = new Hashtable<String, String>();
		
		while (this.tokens.hasMoreElements())
		{
			String token = this.tokens.nextToken();
			String[] param = token.split("=");
			this.map.put(param[0], param[1]);
		}
	}
	
	/**
	 * getArgument retrives the value for the passed in argument.
	 */
	public String getArgument(String argument)
	{
		return this.map.get(argument);
	}
}
